package org.jmhome.blog.model;

import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

@Entity
@Table(name = "BLOG_USER")
@NamedQueries({
		@NamedQuery(name = "org.jmhome.blog.model.User@Users", query = "from User as user order by boardSeq desc"),
		@NamedQuery(name = "org.jmhome.blog.model.User@UserByEmail", query = "from User as user where email = :email") })
public class User {

	@Id
	private String email;

	private String name;

	private String password;

	@Temporal(TemporalType.DATE)
	private Date birthDate;

	private String gender;

	@Temporal(TemporalType.TIMESTAMP)
	private Date regDate;

	@Temporal(TemporalType.TIMESTAMP)
	private Date modDate;

	@OneToMany(targetEntity = Board.class, mappedBy = "user", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
	private List<Board> board;

	@OneToOne(mappedBy="blogUser", cascade={CascadeType.ALL})
	private Role role;
	/*@OneToMany(targetEntity = Category.class, mappedBy = "user", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
	private List<Category> boardCategory;*/

	public User() {
		super();
	}

	public User(String email, String name, String password, Date birthDate,
			String gender, Date regDate, Date modDate) {
		super();
		this.email = email;
		this.name = name;
		this.password = password;
		this.birthDate = birthDate;
		this.gender = gender;
		this.regDate = regDate;
		this.modDate = modDate;
	}

	/**
	 * @return the email
	 */
	public String getEmail() {
		return email;
	}

	/**
	 * @param email
	 *            the email to set
	 */
	public void setEmail(String email) {
		this.email = email;
	}

	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}

	/**
	 * @param name
	 *            the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * @return the password
	 */
	public String getPassword() {
		return password;
	}

	/**
	 * @param password
	 *            the password to set
	 */
	public void setPassword(String password) {
		this.password = password;
	}

	/**
	 * @return the birthDate
	 */
	public Date getBirthDate() {
		return birthDate;
	}

	/**
	 * @param birthDate
	 *            the birthDate to set
	 */
	public void setBirthDate(Date birthDate) {
		this.birthDate = birthDate;
	}

	/**
	 * @return the gender
	 */
	public String getGender() {
		return gender;
	}

	/**
	 * @param gender
	 *            the gender to set
	 */
	public void setGender(String gender) {
		this.gender = gender;
	}

	/**
	 * @return the regDate
	 */
	public Date getRegDate() {
		return regDate;
	}

	/**
	 * @param regDate
	 *            the regDate to set
	 */
	public void setRegDate(Date regDate) {
		this.regDate = regDate;
	}

	/**
	 * @return the modDate
	 */
	public Date getModDate() {
		return modDate;
	}

	/**
	 * @param modDate
	 *            the modDate to set
	 */
	public void setModDate(Date modDate) {
		this.modDate = modDate;
	}

	/**
	 * @return the board
	 */
	public List<Board> getBoard() {
		return board;
	}

	/**
	 * @param board
	 *            the board to set
	 */
	public void setBoard(List<Board> board) {
		this.board = board;
	}

	/**
	 * @return the role
	 */
	public Role getRole() {
		return role;
	}

	/**
	 * @param role the role to set
	 */
	public void setRole(Role role) {
		this.role = role;
	}

	/**
	 * @return the boardCategory
	 */
/*	public List<Category> getBoardCategory() {
		return boardCategory;
	}*/

	/**
	 * @param boardCategory
	 *            the boardCategory to set
	 */
/*	public void setBoardCategory(List<Category> boardCategory) {
		this.boardCategory = boardCategory;
	}*/

	
}
